<template>
  <div id="app">
    <!-- 只是演示使用方法，用于组件或者路由切换时生效 -->
    <keep-alive v-if="$route.meta.keepAlive">
      <router-view />
    </keep-alive>
    <router-view v-else />
  </div>
</template>
<script>
export default {
  name: "App",
  provide() {
    return {
      switchTheme: this.switchMode
    }
  },
  methods: {
    // 初始化mode, 这里可以放在html中的script中
    initMode() {
      if(localStorage.mode) {
        document.body.setAttribute('mode', 'dark')
      }
    },
    // 切换mode
    switchMode() {
      let mode = document.body.getAttribute('mode')
      if(mode === 'dark') {
        document.body.removeAttribute('mode', 'dark')
        localStorage.removeItem('mode')
      } else {
        document.body.setAttribute('mode', 'dark')
        localStorage.setItem('mode', 'dark')
      }
    }
  },
  mounted() {
    this.$toast("你好呀");
  },
};
</script>
<style lang="less">
body,html {
  width: 100%;
  height: 100%;
}
#app {
  width: 100%;
  height: 100%;
  max-width: 1024PX;
  margin: 0 auto;
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
</style>
